package com.lbt.mybatis.plus.extend.bean;

import cn.hutool.core.util.StrUtil;
import com.lbt.mybatis.plus.extend.expression.SqlExpression;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @author zhangjinyu
 * @since 2023-05-16
 */
@Slf4j
@Data
public class QueryFieldObject {
    private String sqlTable;
    private String sqlColumn;
    private Object sqlColumnValue;
    private SqlExpression sqlExpression;
    private Class<?> fieldType;
    private int unionIndex;
    private boolean resultWrap;
    private Boolean nullValue;

    public boolean unionWrapConflict() {
        return unionIndex != -1 && resultWrap;
    }

    public String getSqlColumn() {
        return resultWrap ? sqlColumn : StrUtil.isBlank(sqlTable) ? sqlColumn : StrUtil.join(".", sqlTable, sqlColumn);
    }
}
